package com.hongdee.market.costtag.service.impl;

import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.hongdee.market.costtag.mapper.ICostTagMapper;
import com.hongdee.market.costtag.pojo.CostTagPoJo;
import com.hongdee.market.costtag.service.ICostTagService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Map;

/**
 * @author zhangkai
 * @desc 一句话描述
 **/
@Service
public class CostTagServiceImpl implements ICostTagService {
    @Autowired
    ICostTagMapper costTagMapper;

    /***
     * 营销预计-基础配置-消费类别定义-分页查询
     * @param companyId
     * @param page
     * @param limit
     * @return
     */
    @Override
    public PageInfo<CostTagPoJo> page(int page, int limit, String companyId) {
        PageHelper.startPage(page, limit);
        List ls = costTagMapper.list(companyId);
        PageInfo<CostTagPoJo> pageInfo = new PageInfo<>(ls);
        return pageInfo;
    }

    /**
     * 营销预计-基础配置-消费类别定义-保存更新
     *
     * @param data
     * @throws Exception
     */
    @Override
    public void save(CostTagPoJo data) throws Exception {
        if (data.getId() == null || data.getId().length() == 0) {
            costTagMapper.Insert(data);
        } else {
            costTagMapper.UpdatePoJo(data);
        }

        System.out.println(data.getId());
    }

    /**
     * 营销预计-基础配置-消费类别定义-修改状态
     *
     * @param id
     * @param status
     */
    @Override
    public void updateStatus(String id, String status) {
        costTagMapper.UpdateStatus(id, status);
    }

    /**
     * 营销预计-基础配置-消费类别定义-详情
     *
     * @param id
     * @return
     */
    @Override
    public CostTagPoJo info(String id) {
        CostTagPoJo po = costTagMapper.Info(id);
        return po;
    }
}
